<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
$appcontent=dirname(__FILE__).'/protected/components/AppContent.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
require_once($appcontent);
Yii::createWebApplication($config)->run();


/**
 * @param $errorCode 0:otherError；-1：需要登录;1:正确
 */
function echoToError($errorCode,$message="") {
    header('Content-type: application/json');
    $result = array();
    $result['code'] = $errorCode;
    if (!empty($message)) {
        $result['body'] = $message;
    } else {
        // $result['body'] = "静静等待国际化资源文件推出";
        $result['body'] = Yii::t(_I18N,_ERROR_USER_LOGIN_FAILUE);
    }

    echo json_encode($result);
    die();
}

function echoToMobile($result)
{
    header('Content-type: application/json');
    $resultPak = array();
    $resultPak['code'] = 1;
    if (empty($result)) {
        $resultPak['body'] = null;
    } else {
        $resultPak['body'] = $result;
    }
    Yii::trace(json_encode($resultPak));
    echo json_encode($resultPak);
}

function echoStringToMobile($result)
{
    header('Content-type: application/json');
    Yii::trace($result);
    echo $result;
}


